<template>
  <div id="app">
    <div class="head">
      <el-menu
              :default-active="activeIndex2"
              class="el-menu-demo"
              mode="horizontal"
              @select="handleSelect"
              background-color="#545c64"
              text-color="#fff"
              active-text-color="#ffd04b">

        <el-menu-item index="1" >首页</el-menu-item>
<!--        <el-submenu index="2">-->
<!--          <template slot="title">视频学习</template>-->
<!--          <el-menu-item index="2-1">java学习</el-menu-item>-->
<!--          <el-menu-item index="2-2">web学习</el-menu-item>-->
<!--          <el-menu-item index="2-3">大数据学习</el-menu-item>-->
<!--        </el-submenu>-->
        <el-menu-item index="2">视频学习</el-menu-item>
        <el-menu-item index="4">题库</el-menu-item>
        <el-menu-item index="3">题解</el-menu-item>
        <el-menu-item index="5">博客</el-menu-item>
        <el-submenu index="6">
          <template slot="title">招聘</template>
          <el-menu-item index="6-1">校园招聘</el-menu-item>
          <el-menu-item index="6-2">全网招聘</el-menu-item>
          </el-submenu>
        <el-menu-item index="7">论坛提问</el-menu-item>
        <el-menu-item index="8">VIP会员</el-menu-item>
        <el-menu-item class="search" >
          <SearchBox  style="display: inline-block; height:30px !important; margin-bottom: 40px"></SearchBox>
        </el-menu-item>
        <el-menu-item index="9" style="margin-left: 80px">动态</el-menu-item>
        <el-submenu index="10">
          <template slot="title" >写作/发布</template>
          <el-menu-item index="10-1">写博客</el-menu-item>
          <el-menu-item index="10-2">写论坛</el-menu-item>
          <el-menu-item index="10-3">发视频</el-menu-item>
        </el-submenu>

          <el-menu-item index="11" v-if="this.$store.state.nickName==''" class="user">登录</el-menu-item>
          <el-menu-item index="11" style="width: 110px;" class="user" v-else >
            <img :src="imgUrl" style="width: 35px; height: 35px; border-radius: 50%" alt="">
                <el-dropdown @command="handleCommand" style="position: absolute; top: -3px">
                <span class="el-dropdown-link" style="color: #fff;">
                  <i class="el-icon-arrow-down el-icon--right"></i>
                </span>
                <el-dropdown-menu slot="dropdown" style="margin-top: 5px; ">
                  <el-dropdown-item command="a">个人中心</el-dropdown-item>
                  <el-dropdown-item command="b">我的博客</el-dropdown-item>
                  <el-dropdown-item command="c">管理博客</el-dropdown-item>
                  <el-dropdown-item command="d">我的钱包</el-dropdown-item>
                  <el-dropdown-item command="e">退出登录</el-dropdown-item>
                </el-dropdown-menu>
                  <span class="vip" v-if="vip != 'NORMAL'">{{vip}}</span>
          </el-dropdown></el-menu-item>



      </el-menu>
    </div>


    <router-view ></router-view>
    <chatPage  ref="child"></chatPage>
<!--   45319c7.610811 0 15.193946 2.048 21.919136 6.088649l91.108324 54.438054-31.494919-75.443892a43.699892 43.699892 0 0 1 11.623784-49.816216c74.170811-64.345946 115.020108-148.729081 115.020108-237.595676C924.090811 276.756757 739.217297 122.713946 512 122.713946S99.909189 276.756757 99.909189 466.058378c0 189.301622 184.873514 343.344432 412.090811 343.344433 65.785081 0 128.719568-12.647784 187.142919-37.583568 5.369081-2.297081 11.07027-3.431784 16.771459-3.431784zM260.953946 470.154378a56.32 56.32 0 0 1 56.347676-56.015567 56.347676 56.347676 0 0 1 55.794162 56.596757c0 31.135135-24.908108 56.430703-55.794162 56.569081A56.32 56.32 0 0 1 260.981622 471.316757v-1.134703z m186.478703 0c0 31.965405 25.710703 57.897514 57.399351 57.897514a57.648432 57.648432 0 0 0 57.371676-57.897514 57.648432 57.648432 0 0 0-57.371676-57.897513 57.648432 57.648432 0 0 0-57.399351 57.897513z m186.506378 0a56.32 56.32 0 0 1 56.347676-56.015567 56.347676 56.347676 0 0 1 55.794162 56.596757c0 31.135135-24.908108 56.430703-55.794162 56.569081a56.32 56.32 0 0 1-56.347676-56.015568v-1.134703z" p-id="4045"></path></svg></div>-->
    <customer-service></customer-service>
  </div>


</template>
<script>
  import SearchBox from "./components/common/search-box"
  import chatPage from "./views/chat/chat"
  import CustomerService from "./components/common/customerService";
  export default {
    name: "App",
    components: {CustomerService},
    data() {
      return {
          imgUrl: sessionStorage.getItem('imgUrl'),
          cnt: 0,
        show_chat: 0,
        vip:sessionStorage.getItem("vip").toLocaleUpperCase()
      }
    },
    methods: {
      getMsgFormSon(data){
          console.log(data)
      },
      showChat(){
        this.$refs.child.showChatS();
        this.show_chat ^= 1;
      },
      handleCommand(command) {
        if(command == 'e'){
            sessionStorage.clear();
           this.$store.state.logining = false;
            location.reload();
        }
        if(command == 'a'){
          this.$router.replace('/information');
        }
      },
      fun1(){
        this.$router.replace("/home");
      },
      fun2(){
        this.$router.replace("/about");
      },
      handleSelect(key, keyPath) {

        /*console.log(sessionStorage.getItem('nickName') == null);
        console.log(key == "11");*/
       if(key == "11" && sessionStorage.getItem('nickName') == null){
         //alert();
         this.$router.replace("/login");
       }
       if(key == "1"){
         this.$router.replace("/home");
       }
       if(key == '2'){
         this.$router.replace("/video");
       }
       if(key[0] == '3'){
         this.$router.replace("/questionSave");
       }
       if(key == '10-1'){
         this.$router.replace("/editor");
       }
       if(key == '10-2'){
         this.$router.replace("/forum");
       }
       if(key == '10-3'){
         this.$router.replace("/uploadVideo");
       }
       if(key == '4'){
         this.$router.replace("/questionBank");
       }
       if(key == '5'){
         this.$router.replace("/blog");
       }
       if(key == '6-1' || key == '6-2'){
         this.$router.replace("/recruit");
       }
       if(key == '7'){
         this.$router.replace("/forums");
       }
       if(key == '8'){
         this.$router.replace("/vip");
       }
       if(key == '9'){
         this.$router.replace("/dynamic");
       }

      }
    },
    comments: {

    },
    components: {
       SearchBox,
      chatPage,
      CustomerService
    },
    created () {
      setTimeout(() => {
        window.L2Dwidget.init({
          "model": { "jsonPath":"https://unpkg.com/live2d-widget-model-miku@1.0.5/assets/miku.model.json", "scale": 1, "hHeadPos":0.5, "vHeadPos":0.618 },
          "display": { "position": "left", "width": 100, "height": 300, "hOffset": 0, "vOffset": 0 },
          "mobile": { "show": true, "scale": 0.5 },
          "react": { "opacityDefault": 0.7, "opacityOnHover": 0.2 }
        });
      }, 1000)
    }
  }
</script>
<style>
  @import "assets/css/base.css";
  @import "assets/css/normalize.css";
  .vip{
    display: inline-block;
    /*color: rgb(255, 208, 75);*/
    -webkit-line-clamp: 2;
    /*background-image: -webkit-linear-gradient(bottom, rgba(251,84,62,1),rgba(245,134,89,1));*/
    background-image: -webkit-linear-gradient(left, rgb(245, 187, 19), rgb(252, 255, 179));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    width: 50px;
    text-align: center;
    font-size: 20px;
    font-weight: bold;
    font-family: "Adobe 楷体 Std R";
  }
  .el-dropdown-link {
    cursor: pointer;
    color: #409EFF;
  }
  .el-icon-arrow-down {
    font-size: 12px;
  }
  .search input{
    border-radius: 5px 0 0 5px !important;
  }
  a{
    text-decoration: none;
  }
  #app{
    width: 100%;
  }
  .head{
    width: 100%;
    background-color: rgb(84, 92, 100);
    position: relative;
  }
  .el-menu-demo{
    width: 1400px;
    margin:  0 auto !important;
  }
  .search input{
    outline: none;
    border-radius: 5px;
  }
  .search:hover{
    color: rgb(255, 255, 255);
    border-bottom-color: transparent;
    background-color: rgb(84, 92, 100) !important;
  }

  .icon-chat{
    display: inline-block;
    width: 50px;
    height: 50px;
    display: inline-block;
    width: 50px;
    height: 50px;
    position: fixed;
    right: 100px;
    bottom: 50px;
    cursor: pointer;
  }
  .icon-chat svg{
    display: inline-block;
    width: 50px;
    height: 50px;
    position: fixed;
    right: 100px;
    bottom: 50px;
    cursor: pointer;
  }
  .icon-chat:hover{
    color: #f40;
    background-color: #62b038;
  }

  .el-menu.el-menu--horizontal{
    border: none !important;
  }
</style>
